﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace CExcelOp.BLL
{

    public interface IDALFactory
    {
        /// <summary>
        /// 更新一条或多条数据
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="dr">要更新成这条数据</param>
        /// <param name="columnNames">条件字段</param>
        /// <param name="values">条件值</param>
        void Update(string tableName, DataRow dr, string[] columnNames, string[] values);

        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="columns">条件字段</param>
        /// <param name="values">条件值</param>
        void Delete(string tableName, string[] columns, string[] values);

        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="dt">要添加的数据集</param>
        void Add(string tableName, DataTable dt);
        void Add(string tableName, DataRow dr);

        /// <summary>
        /// 查询表格
        /// </summary>
        /// <param name="sql">完整的sql语句</param>
        /// <returns></returns>
        DataTable Select(string sql);
        DataTable Select(string tableName, string[] filterColumns, string[] value);

        /// <summary>
        /// 判断一条数据是否存在
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="columnName">列名</param>
        /// <param name="columnValue">值</param>
        bool IsExist(string tableName, string columnName, string columnValue);
        bool IsExist(string tableName, string[] columnNames, string[] columnValues);

        /// <summary>
        /// 获取表格的字段属性信息，包括名称，字段类型，长度，是否为空的信息
        /// </summary>
        DataTable GetTableInfo(string tabName);

        /// <summary>
        /// 获取数据表的空表结构
        /// </summary>
        /// <param name="tabName"></param>
        /// <returns></returns>
        DataTable GetTableColumns(string tabName);
    }
}
